﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.Linq;
using System.Data.Linq.Mapping;

namespace WindowsFormsApp1
{
    [Database(Name = "UFDATA_001_2020")]
    public class clsDataContext  : DataContext
    {


        public clsDataContext(string connection) : base(connection) { }
        public Table<clsPoMain> persons;
        public Table<clsPoMain> poMains;
        public Table<clsPODetails> poDetails;
    }


    public class  ClsLotusDataContext
    {
        //public static clsDataContext db = new clsDataContext("Server=192.168.0.11;Database=lotus;uid=sa;pwd=mysql@2021"); //这里的连接字符串根据自己的配置进行相应更改即可Table<Category>
        public static clsDataContext db = new clsDataContext("Server=192.168.0.12;Database=UFDATA_001_2020;uid=sa;pwd=123.com"); //这里的连接字符串根据自己的配置进行相应更改即可Table<Category>
        public static List<clsPoMain> GetTables()
        {
            Table<clsPoMain> poMain = db.GetTable<clsPoMain>();
            var query = from c in poMain
                        select c;
            List<clsPoMain> list = new List<clsPoMain>();
            foreach (var v in query)
            {
                list.Add(v);
                System.Console.WriteLine(v.cPOID);
            }
            return list;
        }

        public static List<clsPersons> GetPersons()
        {
            Table<clsPersons> poMain = db.GetTable<clsPersons>();
            var query = from c in poMain
                        select c;
            List<clsPersons> list = new List<clsPersons>();
            foreach (var v in query)
            {
                list.Add(v);
            }
            return list;
        }
        public Table<clsPersons> persons;
    }

}
